
let productArr=[
  {
    id:'1',
    productName: "测试产品1",
    prem:1000,
    iconUrl:'https://img2.baidu.com/it/u=1219224580,1513624071&fm=253&fmt=auto&app=138&f=JPEG?w=753&h=500',
    riskFactor: [
      { factorValueName: "30万" },
      { factorValueName: "终身" },
      { factorValueName: "10年" },
    ],
  },
  {
    id:'2',
    prem:1400,
    productName: "测试产品2",
    iconUrl:'https://img2.baidu.com/it/u=1219224580,1513624071&fm=253&fmt=auto&app=138&f=JPEG?w=753&h=500',
    riskFactor: [
      { factorValueName: "30万" },
      { factorValueName: "终身" },
      { factorValueName: "10年" },
    ],
  },
  {
    id:'3',
    prem:1200,
    productName: "测试产品3",
    iconUrl:'https://img2.baidu.com/it/u=1219224580,1513624071&fm=253&fmt=auto&app=138&f=JPEG?w=753&h=500',
    riskFactor: [
      { factorValueName: "30万" },
      { factorValueName: "终身" },
      { factorValueName: "10年" },
    ],
  }
]

let productDicts=[
  {
    id:1,
    label: "全部",
  },
  {
    id:2,
    label: "寿险",
  },
  {
    id:3,
    label: "健康险",
  },
  {
    id:4,
    label: "意外险",
  },
  {
    id:5,
    label: "责任险",
  },
]

let dutyList=[
  {
    type:'amnt',
    factorName:'保额',
    pbRiskFactors:[
      {
        id:1,
        factorValueName:'5万',
        isDefault:1
      },
      {
        id:2,
        factorValueName:'20万',
        isDefault:0
      },
      {
        id:3,
        factorValueName:'30万',
        isDefault:0
      },
      {
        id:4,
        factorValueName:'40万',
        isDefault:0
      },
    ]
  },
  {
    type:'payYear',
    factorName:'交费期间',
    pbRiskFactors:[
      {
        id:5,
        factorValueName:'趸交',
        isDefault:0
      },
      {
        id:6,
        factorValueName:'5年',
        isDefault:1
      },
      {
        id:7,
        factorValueName:'10年',
        isDefault:0
      },
    ]
  },
  {
    type:'time',
    factorName:'保障期间',
    pbRiskFactors:[
      {
        id:8,
        factorValueName:'终身',
        isDefault:1
      },
      {
        id:9,
        factorValueName:'到70岁',
        isDefault:0
      },
    ]
  }
]

let pbRisks=[
  {
    riskName:'两全险'
  },
  {
    riskName:'学平险'
  },
]

class TempController {
  // 商品
  async list(ctx, next) {
    try {
      ctx.success(productArr);
    } catch (error) {
      console.log(error)
    }
  }

  // 类型
  async params(ctx, next) {
    try {
      ctx.success({
        productDicts: productDicts,
      });
    } catch (error) {
      console.log(error)
    }
  }

  // 单个产品
  async productDetail(ctx, next) {
    const { productId } = ctx.query;
    try {
      let obj={}
      for(let i of productArr){
        if(i.id==productId){
          obj=i
          break
        }
      }
      ctx.success(obj);
    } catch (error) {
      console.log(error)
    }
  }

  // 保障责任
  async Guarantee(ctx, next) {
    const { productId } = ctx.query;
    try {
      ctx.success({
        list: dutyList,
        pbRisks:pbRisks
      });
    } catch (error) {
      console.log(error)
    }
  }

}

module.exports = new TempController();
